package mt.client;

import static org.junit.Assert.*;
import mt.Order;

import org.junit.Test;

public class StockResumeTest {

	

	@Test
	public void testGetTotalUnits() {
		StockResume sr = new StockResume.BuyOrdersResume("GALP");
		assertEquals(0, sr.getTotalUnits());
		sr.addOrder(Order.createBuyOrder("Manel", "GALP", 10, 1));
		sr.addOrder(Order.createBuyOrder("Ze", "GALP", 15, 9));
		assertEquals(25, sr.getTotalUnits());
		
	}

	@Test
	public void testGetMedianPrice() {
		StockResume sr = new StockResume.BuyOrdersResume("GALP");
		assertEquals(0, sr.getMedianPrice(), 0);
		sr.addOrder(Order.createBuyOrder("Manel", "GALP", 10, 1));
		sr.addOrder(Order.createBuyOrder("Ze", "GALP", 15, 9));
		assertEquals(5, sr.getMedianPrice(), 0);
		
	}

	@Test
	public void testGetLowestPrice() {
		StockResume sr = new StockResume.SellOrdersResume("GALP");
		assertEquals(0, sr.getLowestPrice(), 0);
		sr.addOrder(Order.createSellOrder("Ze", "GALP", 15, 9));
		sr.addOrder(Order.createSellOrder("Manel", "GALP", 10, 1));
		assertEquals(1, sr.getLowestPrice(), 0);
	}

	@Test
	public void testGetHighestPrice() {
		StockResume sr = new StockResume.SellOrdersResume("GALP");
		assertEquals(0, sr.getHighestPrice(), 0);
		sr.addOrder(Order.createSellOrder("Ze", "GALP", 15, 9));
		sr.addOrder(Order.createSellOrder("Manel", "GALP", 10, 1));
		assertEquals(9, sr.getHighestPrice(), 0);
	}

}
